home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscProgressPalette / MiscProgressView.subproj / MiscProgressPie.m < prev    next >
Text File  |  1995-04-12  |  2KB  |  91 lines

  1. //
  2. //    MiscProgressPie.m -- a simple view class for displaying a pie
  3. //        Written and Copyright (c) 1993 by James Heiser.  (jheiser@adobe.com)
  4. //                Rendering code massaged by Don Yacktman.
  5. //                Version 1.0.  All rights reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the author
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14.  
  15. #import "MiscProgressPie.h"
  16.  
  17. @implementation MiscProgressPie
  18.  
  19. - initFrame:(const NXRect *)frameRect
  20. {
  21.     [super initFrame:frameRect];
  22.     [self setHidden:NO];
  23.     return self;
  24. }
  25.  
  26. - renderBar
  27. {
  28.     float angle = 90.0;
  29.     if ([self isHidden] || (ratio <= 0.0)) return self;
  30.     if (ratio >= 1.0) angle = -270.0;
  31.     if (ratio < 1.0 && ratio > 0.0) angle = 90.0 - 360.0 * ratio;
  32.     PSmoveto (NX_WIDTH(&bounds) / 2.0, NX_HEIGHT(&bounds) / 2.0);
  33.     PSarcn (NX_WIDTH(&bounds) / 2.0, NX_HEIGHT(&bounds) / 2.0,
  34.             NX_HEIGHT(&bounds) / 2.0, 90.0, angle);
  35.     PSclosepath ();
  36.     NXSetColor(fg);
  37.     PSfill();
  38.     return self;
  39. }
  40.  
  41. - renderBorder
  42. {
  43.     float angle = 90.0;
  44.     if ([self isHidden]) return self;
  45.     NXSetColor(bd);
  46.     PSarc ((bounds.size.width / 2), (bounds.size.height / 2),
  47.             (bounds.size.height / 2), 0.0, 360.0);
  48.     PSstroke();
  49.     if (ratio >= 1.0) angle = -270.0;
  50.     if ((ratio < 1.0) && (ratio > 0.0)) angle = 90.0 - 360.0 * ratio;
  51.     PSmoveto (NX_WIDTH(&bounds) / 2.0, NX_HEIGHT(&bounds) / 2.0);
  52.     PSarcn (NX_WIDTH(&bounds) / 2.0, NX_HEIGHT(&bounds) / 2.0,
  53.             NX_HEIGHT(&bounds) / 2.0, 90.0, angle);
  54.     PSclosepath();
  55.     PSstroke();
  56.     return self;
  57. }
  58.  
  59. - setHidden:(BOOL)aBool
  60. {
  61.     isHidden = aBool;
  62.     return self;
  63. }
  64.  
  65. - (BOOL)isHidden
  66. {
  67.     return isHidden;
  68. }
  69.  
  70. - read:(NXTypedStream*)stream
  71. {
  72.     [super read:stream];
  73.     NXReadTypes(stream, "c", &isHidden);
  74.     return self;
  75. }
  76.  
  77. - write:(NXTypedStream*)stream
  78. {
  79.     [super write:stream];
  80.     NXWriteTypes(stream, "c", &isHidden);
  81.     return self;
  82. }
  83.  
  84. - (const char *)getInspectorClassName
  85. {
  86.      return "MiscProgressPieInspector";
  87. }
  88.  
  89.  
  90. @end
  91.